<script setup>
import { onMounted } from 'vue';
import { useRouter } from 'vue-router';
const { currentRoute } = useRouter();
const router = useRouter();
import { token } from "@/utils/api.js"

// 正式发布
const gettoken = async () => {
    let res = await token(currentRoute.value.query.id)
    if (res.status == 'success') {
        window.sessionStorage.setItem('zhName', res.logInfo.zhName);
        window.sessionStorage.setItem('mobile', res.logInfo.zhName);
        window.sessionStorage.setItem('areaId', res.data);
        router.push({ path: '/enterGarden' });
    } else {
        alert('服务器异常，请稍后再试')
    }
}

// 测试
const login = () => {
    window.sessionStorage.setItem('zhName', '汉石桥');
    window.sessionStorage.setItem('mobile', '18201550364');
    window.sessionStorage.setItem('areaId', '0000147');
    router.push({ path: '/enterGarden' });
}

onMounted(() => {
    // 正式发布
    if (currentRoute.value.query.id == undefined) {
        alert('您暂无权限查看，请登录后再查看')
    } else {
        gettoken();
    }

    // 测试
    // login();
})

</script>
<template>
    <div>

    </div>
</template>
<style scoped></style>